import React, {Component} from 'react';
import {
    View,
    AppRegistry,
    Switch,
    StyleSheet,
    Dimensions
} from "react-native";

const {width} = Dimensions.get('window')


class Notify extends Component {
    state = {
        value: false
    };
    onchange () {
        let values = this.state.value
        this.setState({
           value:!values
        })
    }
    render() {

        return (
            <View style={styles.switchBody}>
                <View style={styles.switchContainer}>
                    <Switch
                        style={styles.switch}
                        value={this.state.value}
                        onTintColor={'#ffaa11'}
                        tintColor={'#D8D8D8'}
                        thumbColor={'#FE2E2E'}
                        //当切换开关室回调此方法
                        onValueChange={(value)=>{this.onchange()}}
                    />

                </View>

                <Switch
                    // style={{marginTop: 120}}
                    //动态改变value
                    // value={this.state.value}
                    //当切换开关室回调此方法
                    // onValueChange={(value)=>{this.setState({value: true})}}
                />
            </View>
        );
    }
}

export default Notify;

const styles = StyleSheet.create({
    switchBody :{
        flex:1,
        // flexDirection:"row",
        justifyContent:"space-around",
        alignItems:"center"

    },
    switchContainer: {
        width:width,
        height: 35,
        backgroundColor:"#FFF",


    },
    switch:{
        // marginBottom:10,marginTop:10,
        backgroundColor: '#FA58D0',
        // borderWidth:5,
        // transform: [{ scaleX: 1.4 }, { scaleY: 1.4}], marginRight: 16
        // marginTop:20
        width: 40,
        // height:35,

    }


})
